NULL |
It is a special value used in a relational database to indicate that there is not any stored value. It is used to specify that there is no information about the value in the database, and it is used to indicate that a value is optional. Es un valor especial usado en las bases de datos relacionales para indicar que no hay ningún valor almacenado. Este sirve para especificar que no se tiene información sobre un valor almacenado en la base de datos y es usualmente usado para indicar que un valor es opcional. |
Problem 1 |
Indicate if the next statement is true of false: The NULL value in the SQL language is used for optional values. Because, it increases the flexibility of the database, it is recommended to use as much as possible NULL. Diga si es verdadero o falso: La palabra NULL del lenguaje SQL convierte un valor en opcional. Debido a que esto aumenta la flexibilidad de la base de datos, se recomienda usar lo más posible NULL. |
Tip |
When defining an attribute, we must not only state its domain, but also state whether or not its domain includes the value NULL. For instance, in the employee table shown below, the last employee in the table does not have any skill. In this case, it is said that the employee with emp_id 105 has a NULL value for skill. NULL is a special value to indicate no equal to anything. Thus, it can be said that two employees with a NULL value for skill DO NOT have the same skill. Cuando se define un atributo se debe proporcionar el dominio indicando si este dominio incluye el valor de NULL. Por ejemplo, en la tabla employee mostrada debajo, al último empleado en la tabla no se le ha asignado una skill (habilidad). En este caso, se dice que el empleado con emp_id 105 tiene un valor de NULL para skill. NULL es un valor especial que indica no igual a nada. De esta forma se puede decir que dos empleados con un atributo NULL para skill no tienen la misma skill. |
Problem 2 |
Provide the name of three attributes that:
De el nombre de tres atributos que
|
Problem 3 |
Create a SQL script to create the employee table shown below inside the cfe database. The script must insert the employees in the table. Check your results by executing SELECT * from employee.
|
cfe.sql |
-- _____________________________________________ MySQL DROP DATABASE IF EXISTS cfe; CREATE DATABASE cfe; USE cfe; CREATE TABLE employee ( emp_id INT NOT NULL PRIMARY KEY, -- INT(4) first_name NVARCHAR(15) NOT NULL, last_name NVARCHAR(20) NOT NULL, skill NVARCHAR(25) NULL ); INSERT INTO employee VALUES (100, 'Steven', 'King', 'C++'); ... |
cfe.sql |
-- _____________________________________________ Oracle DROP TABLE employee; -- Observe that there is a 2 after NVARCHAR CREATE TABLE employee ( emp_id INT NOT NULL PRIMARY KEY, first_name NVARCHAR2(15) NOT NULL, -- NVARCHAR last_name NVARCHAR2(20) NOT NULL, -- NVARCHAR skill NVARCHAR2(25) NULL ); INSERT INTO employee VALUES (100, 'Steven', 'King', 'C++'); ... |
cfe.sql |
-- _____________________________________________ Microsoft SQL Server USE master; GO IF EXISTS(SELECT * FROM sysdatabases WHERE name='cfe') BEGIN RAISERROR('Dropping existing cfe database...', 0, 1) DROP DATABASE cfe; END GO CREATE DATABASE cfe; GO USE cfe; GO IF db_name() <>'cfe' BEGIN RAISERROR('Use database failed...', 22, 127) WITH LOG DROP DATABASE cfe; END GO CREATE TABLE employee ( emp_id INT NOT NULL PRIMARY KEY, first_name NVARCHAR(15) NOT NULL, last_name NVARCHAR(20) NOT NULL, skill NVARCHAR(25) NULL ); GO INSERT INTO employee VALUES (100, 'Steven', 'King', 'C++'); ... GO |